﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Core;

namespace DataAccess
{
    public class PhieuChi_Info
    {
        public string maphieu { get; set; }
        public DateTime ngaylap { get; set; }
        public string hovaten { get; set; }
        public string noidung { get; set; }
        public string sotien { get; set; }
        public string bangchu { get; set; }
        public static List<PhieuChi_Info> GetByID(string mapt)
        {
            return CBO.FillCollection<PhieuChi_Info>(DataProvider.Instance.ExecuteReader("PhieuChi_GetByID", mapt));
        }
        public static DataSet DsGetByID(string mapt)
        {
            return DataProvider.Instance.ExecuteDataset("PhieuChi_GetByID", mapt);
        }
        public static List<PhieuChi_Info> GetAll()
        {
            return CBO.FillCollection<PhieuChi_Info>(DataProvider.Instance.ExecuteReader("PhieuChi_GetAll"));
        }
        public static bool Add(string maphieu, DateTime ngaylap, string manv,string noidung, decimal sotien, string bangchu)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("PhieuChi_Insert", maphieu, ngaylap, manv, noidung, sotien, bangchu);
                return Convert.ToInt32(rs) > 0;
            }
            catch (Exception e)
            {
                return BatLoi.ThongBao(e.Message);
            }
        }
        public static bool Delete(string maphieu)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("PhieuChi_Delete", maphieu);
                return Convert.ToInt32(rs) > 0;
            }
            catch (Exception)
            {
            }
            return false;
        }
        public static bool Update(string maphieu, DateTime ngaylap, string noidung, decimal sotien, string bangchu)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("PhieuChi_Update", maphieu, ngaylap,noidung, sotien, bangchu);
                return Convert.ToInt32(rs) > 0;
            }
            catch (Exception e)
            {
                return BatLoi.ThongBao(e.Message);
            }
        }

    }
}
